import { createRouter, createWebHistory } from "vue-router";
import Layout from "../components/Layout.vue";
import Login from "../views/Login.vue";

const routes = [
    {
        path: "/",
        redirect: "/login",
    },
    {
        path: "/login",
        name: "Login",
        component: Login,
    },
    {
        path: "/admin",
        component: Layout,
        redirect: "/admin/article-management",
        children: [
            {
                path: "article-management",
                name: "ArticleManagement",
                component: () => import("../views/admin/ArticleManagement.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "user-management",
                name: "UserManagement",
                component: () => import("../views/admin/UserManagement.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "dailySentence",
                name: "dailySentence",
                component: () => import("../views/admin/DailySentence.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "extendArticleType",
                name: "extendArticleType",
                component: () => import("../views/admin/ExtendArticleType.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "extendArticle",
                name: "extendArticle",
                component: () => import("../views/admin/ExtendArticle.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "banner",
                name: "banner",
                component: () => import("../views/admin/BannerList.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "etymologyType",
                name: "etymologyType",
                component: () => import("../views/admin/EtymologyType.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "etymology",
                name: "etymology",
                component: () => import("../views/admin/Etymology.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "enWords",
                name: "enWords",
                component: () => import("../views/admin/EnWords.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "typeList",
                name: "typeList",
                component: () => import("../views/admin/TypeList.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "shopList",
                name: "shopList",
                component: () => import("../views/admin/ShopList.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "productList",
                name: "productList",
                component: () => import("../views/admin/ProductList.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
            {
                path: "orderList",
                name: "orderList",
                component: () => import("../views/admin/OrderList.vue"),
                meta: { requiresAuth: true, permissions: ["admin"] },
            },
        ],
    },
];

const router = createRouter({
    history: createWebHistory(),
    routes,
});

export default router;
